package cz.zcu.fav.rat.beans;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;

@Indexed
public class ObjectClass implements Serializable, Indexable
{
	private static final long serialVersionUID = 1L;
	private Integer id;
	private String name;
	private String description;
	private Set<Object> objects = new HashSet<Object>();
	private boolean pickable;
	private boolean returnable;

	@DocumentId
	public Integer getId()
	{
		return id;
	}
	
	public void setId(Integer id)
	{
		this.id = id;
	}

    @Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO)
	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public String getDescription()
	{
		return description;
	}

	public void setDescription(String description)
	{
		this.description = description;
	}

	public Set<Object> getObjects()
	{
		return objects;
	}

	public void setObjects(Set<Object> objects)
	{
		this.objects = objects;
	}
	
	public void addObject(Object object)
	{
		objects.add(object);
	}

	public boolean isPickable()
	{
		return pickable;
	}

	public void setPickable(boolean pickable)
	{
		this.pickable = pickable;
	}

	public boolean isReturnable()
	{
		return returnable;
	}

	public void setReturnable(boolean returnable)
	{
		this.returnable = returnable;
	}

	@Override
	public int hashCode()
	{
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((description == null) ? 0 : description.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + (pickable ? 1231 : 1237);
		result = prime * result + (returnable ? 1231 : 1237);
		return result;
	}

	@Override
	public boolean equals(java.lang.Object obj)
	{
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ObjectClass other = (ObjectClass) obj;
		if (description == null)
		{
			if (other.description != null)
				return false;
		} else if (!description.equals(other.description))
			return false;
		if (id == null)
		{
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (name == null)
		{
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (pickable != other.pickable)
			return false;
		if (returnable != other.returnable)
			return false;
		return true;
	}




}
